package fr.babos.test.di 
{
	import com.hasbro.listenoel.models.EditorModel;
	import com.hasbro.listenoel.models.ListModel;
	import flash.display.Sprite;
	import flash.utils.getQualifiedClassName;
	import flash.utils.getQualifiedSuperclassName;
	import flash.utils.setTimeout;
	import fr.babos.core.data.items.IDataItem;
	import fr.babos.core.data.parse.DataParser;
	import fr.babos.core.data.remote.ADataRemote;
	import fr.babos.core.data.remote.XMLRemote;
	import fr.babos.core.dependences.DependencesManager;
	import fr.babos.core.log.Log;
	import fr.babos.core.log.MonsterLogger;
	import fr.babos.core.log.TraceLogger;
	import fr.babos.core.mvc.Controller;
	import fr.babos.core.mvc.IController;
	import fr.babos.core.mvc.IModel;
	import fr.babos.core.mvc.Model;
	
	/**
	 * @author ZoulouX
	 */
	public class DependencesManagerTest extends Sprite 
	{
		public var controller:TestDIController;
		
		/**
		 * 
		 */
		public function DependencesManagerTest ()
		{
			Log.addLogger(new MonsterLogger(this));
			Log.addLogger(new TraceLogger());
			
			// 
			setTimeout(testDI, 500);
		}
		
		/**
		 * 
		 */
		public function testDI ():void
		{
			var dependencesManager:DependencesManager = new DependencesManager();
			
			dependencesManager.addConcrete(IModel, new EditorModel());
			
			dependencesManager.addDependences(Controller, {
				a: "test low",
				c: IModel
			});
			dependencesManager.addDependences(TestDIController, {
				a: "test high",
				b: XMLRemote
			});
			dependencesManager.addDependences(XMLRemote, {
				parser: new DataParser()
			});
			
			dependencesManager.inject(this, {
				controller: TestDIController
			});
			
			//Log.debug("dependences", dependencesManager.getDependencesForObject(TestDIController));
			
			Log.log(this.controller);
			Log.log(this.controller.a);
			Log.log(this.controller.b);
			Log.log(this.controller.c);
			Log.log(this.controller.b.parser);
			Log.log(dependencesManager.getConcrete(IModel));
			Log.log(dependencesManager.getConcrete(IModel) == this.controller.c);
			
		}
	}
}